package com.huawei.appgallery.forum.cards.card;

import android.content.Context;
import android.text.TextUtils;
import android.widget.ImageView;
import androidx.databinding.ViewDataBinding;
import com.huawei.appgallery.forum.cards.bean.InfoFlowForumCardBean;
import com.huawei.appgallery.forum.cards.widget.PostTitleTextView;
import com.huawei.appgallery.foundation.ui.framework.cardkit.bean.CardBean;
import com.huawei.appgallery.foundation.ui.framework.widget.LineImageView;
import com.huawei.appmarket.service.infoflow.cards.card.BaseInfoFlowCard;
import huawei.widget.HwTextView;
import java.util.ArrayList;
import java.util.List;
import o.bsy.a;
import o.bsy.e;
import o.bte;
import o.epv;
import o.eqx;

public class InfoFlowForumPostCard extends BaseInfoFlowCard<bte> {
    public /* synthetic */ void ˊ(ViewDataBinding viewDataBinding) {
        ॱ((bte) viewDataBinding);
    }

    public InfoFlowForumPostCard(Context context) {
        super(context);
    }

    public void ॱ(bte o_bte) {
        super.ˊ(o_bte);
        o_bte.ˏ.setTextViewWidth(this.ˋ);
    }

    private int ॱ(boolean z, int i) {
        if (z) {
            return (((i - (this.ʼॱ.getResources().getDimensionPixelSize(e.ॱˋ) * 2)) / 3) / 4) * 3;
        }
        return (int) (((float) i) * epv.ʼ());
    }

    public void ˏ(CardBean cardBean) {
        List list;
        CharSequence charSequence;
        List list2;
        int i;
        String str;
        int i2 = 8;
        super.ˏ(cardBean);
        String str2 = "";
        String str3 = "";
        if (cardBean instanceof InfoFlowForumCardBean) {
            InfoFlowForumCardBean infoFlowForumCardBean = (InfoFlowForumCardBean) cardBean;
            List ˊ = infoFlowForumCardBean.ˊ();
            List ʽ = infoFlowForumCardBean.ʽ();
            String O_ = infoFlowForumCardBean.O_();
            str3 = infoFlowForumCardBean.ॱ();
            list = ˊ;
            charSequence = O_;
            list2 = ʽ;
        } else {
            list2 = null;
            list = null;
            Object obj = str2;
        }
        boolean z = list != null && list.size() >= 3;
        LineImageView lineImageView = ((bte) ʾ()).ʽ;
        if (z) {
            i = 0;
        } else {
            i = 8;
        }
        lineImageView.setVisibility(i);
        lineImageView = ((bte) ʾ()).ॱॱ;
        if (z) {
            i = 0;
        } else {
            i = 8;
        }
        lineImageView.setVisibility(i);
        ((bte) ʾ()).ᐝ.getLayoutParams().height = ॱ(z, this.ˋ);
        ((bte) ʾ()).ˋ.setText(charSequence);
        HwTextView hwTextView = ((bte) ʾ()).ˋ;
        if (!TextUtils.isEmpty(charSequence)) {
            i2 = 0;
        }
        hwTextView.setVisibility(i2);
        PostTitleTextView postTitleTextView = ((bte) ʾ()).ˏ;
        if (str3 == null) {
            str = "";
        } else {
            str = str3;
        }
        postTitleTextView.setData(str, list2);
        ˋ(z, list);
    }

    private void ˋ(boolean z, List<String> list) {
        ArrayList arrayList = new ArrayList();
        arrayList.add(((bte) ʾ()).ʼ);
        if (z) {
            arrayList.add(((bte) ʾ()).ʽ);
            arrayList.add(((bte) ʾ()).ॱॱ);
        }
        int i = 0;
        while (i < arrayList.size()) {
            String str = (list == null || list.size() <= i) ? null : (String) list.get(i);
            ˏ(z, str, (ImageView) arrayList.get(i));
            i++;
        }
    }

    private void ˏ(boolean z, String str, ImageView imageView) {
        if (str == null) {
            imageView.setImageResource(a.ʻॱ);
        } else {
            eqx.ˋ(this.ʼॱ.getResources().getDimensionPixelSize(z ? e.ॱᐝ : e.ॱˊ), this.ʼॱ.getResources().getDimensionPixelSize(z ? e.ˏॱ : e.ˊॱ), imageView, str, "image_default_icon");
        }
    }
}
